from selenium import webdriver
import xlrd,time

data = xlrd.open_workbook(u"C:/Users/qinxue/Desktop/BOSS.xls")
sheet1 = data.sheet_by_index(0)


'''标题'''
def c_title(row):
	return sheet1.cell(row, 1).value
'''状态'''
def c_info(row):
	return sheet1.cell(row, 6).value




browser = webdriver.Chrome('C:/Users/qinxue/Desktop/driver/chromedriver.exe')
browser.get('http://192.168.1.240:8080/zentao/my/')
browser.find_element_by_id('account').send_keys('admin')
browser.find_element_by_name('password').send_keys('Really123')
browser.find_element_by_id('submit').click()
browser.get('http://192.168.1.240:8080/zentao/product-browse-8.html')
 

for i in range(1,sheet1.nrows):
	browser.get('http://192.168.1.240:8080/zentao/product-browse-8.html')
	browser.find_element_by_link_text(u'提需求').click()
	browser.find_element_by_id('title').send_keys(c_title(i))
	browser.switch_to.frame(browser.find_element_by_xpath('//*[@id="dataform"]/table/tbody/tr[5]/td/div[3]/div[2]/iframe'))
	browser.find_element_by_class_name('article-content').send_keys(c_info(i))
	browser.switch_to.default_content()
	browser.find_element_by_id('keywords').send_keys('tapd')
	browser.find_element_by_id('submit').submit()
	time.sleep(1)

